//
//  AIFGetValidManager.m
//  PywSdk
//
//  Created by liangyidong on 16/1/26.
//  Copyright © 2016年 zero. All rights reserved.
//

#import "AIFGetCodeManager.h"

@implementation AIFGetCodeManager

NSString *const GetCode_PASSPORT = @"passport";
NSString *const GetCode_TID = @"tid";
NSString *const GetCode_GAMEID = @"gameid";
NSString *const GetCode_SIGN = @"sign";
NSString *const GetCode_SMSTYPE = @"smstype";

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.child = self;
        self.paramSource = self;
        self.validate = self;
    }
    return self;
}


#pragma mark - ETAPIManager
- (NSString *)methodName{
    return URL_SMSCODE;
}

- (ETAPIManagerRequestType)requestType{
    return ETAPIManagerRequestTypePost;
}


- (NSString *)seriviceType{
    return [PywAppInfo sharedAppInfo].seriviceType;
}


#pragma mark - ETAPIManagerParamSourceDelegate
- (NSDictionary *)paramsForApi:(ETApiBaseManager *)manager{
    NSString *tid = [PywAppInfo sharedAppInfo].tid;
    
    NSString *gameid = [PywAppInfo sharedAppInfo].gameId;
    NSString *passport = self.phoneNum;
    NSString *apiSecret2 = [AppUtil getApiSecret2:tid apiSecret:[PywAppInfo sharedAppInfo].apisecret];
    
    NSString *sign = [NSString stringWithFormat:@"%@%@%@", gameid, passport, apiSecret2];
    sign = [PywCipherUtils md5:sign];
    
    NSString *smsType = self.smsType;
    
    MutableDictionary *param = [[MutableDictionary alloc] init];
    [param setObject:passport forKey:GetCode_PASSPORT];
    [param setObject:tid forKey:GetCode_TID];
    [param setObject:gameid forKey:GetCode_GAMEID];
    [param setObject:sign forKey:GetCode_SIGN];
    [param setObject:smsType forKey:GetCode_SMSTYPE];
    return param;
}

#pragma mark - ETAPIManagerValidator
- (BOOL)manager:(ETApiBaseManager *)manager isCorrectWithParamsData:(NSDictionary *)data{
    return YES;
}

- (BOOL)manager:(ETApiBaseManager *)manager isCorrectWithCallBackData:(NSDictionary *)data{
    return YES;
}


@end
